﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class EmployeesSalary_EmpSalaryIdList : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeComponent(false);

            Master.DataSource = WMaster;
            wgvMaster.Visible = false;

         
            MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;
            master.HelpHref = "";
            master.PageName = "员工编号＼薪资编号绑定";
            master.PicUrl = "";
            master.IntiBar();

            ddlStatus.SelectedValue = "1";
        }
    }

    private void InitializeComponent(bool action)
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EmployeesSalary_EmpSalaryIdList));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = action;
        this.WMaster.AlwaysClose = false;
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        this.WMaster.RemoteName = "SEmployees.ViewEmpSalaryId";
        this.WMaster.ServerModify = false;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();

    }
    protected void Search_Click(object sender, EventArgs e)
    {
        //Search.CssClass = "OnHover";
        //IdInti.CssClass = "UnHover";

        string strDep = Depart.SelectDepmanetId;
        if (strDep == "")
        {
            return;
        }
        else if (strDep == "0")
        {
            strDep = "";
        }
        else
        {
            strDep = " And Employees.DepartmentId like ('" + strDep + "%')";
        }

        string strName = txtName.Text;
        if (strName != "")
        {
            strName = " And EmpName like '%" + strName + "%' ";
        }
        else
        {
            strName = "";
        }


        string Status = ddlStatus.SelectedValue;
        if (Status == "-1")
        {
            Status = "";
        }
        else
        {
            Status = " And EmpStatus = " + Status;
        }

        string Sid = ddlSid.SelectedValue;
        if (Sid == "-1")
        {
            Sid = "";
        }
        else if (Sid == "0")
        {
            Sid = " And (SalaryEmpId ='' or SalaryEmpId is null)";
        }
        else
        {
            Sid = " And (SalaryEmpId is not null and SalaryEmpId != '')";
        }

        InitializeComponent(true);

        WMaster.SetWhere("1=1 " + strDep + Status + strName + Sid);

        Master.DataSource = WMaster;

        wgvMaster.Visible = true;
    }

    protected void IdInti_Click(object sender, EventArgs e)
    {
        //EmpSalaryIdInti
      
        object[] obj = new object[] { null };

        object[] ret = Srvtools.CliUtils.CallMethod("SEmployees", "EmpSalaryIdInti", obj);

        if ((bool)ret[1])
        {
            ClientScript.RegisterStartupScript(GetType(), "Msg", "alert('初始化成功');location.href='EmpSalaryIdList.aspx'", true);
        }
        else
        {
            ClientScript.RegisterStartupScript(GetType(), "Msg", "alert('初始化失败');location.href='EmpSalaryIdList.aspx'", true);
        }
    }

   
}
